package com.lei2j.dubbo.producer.service.impl;

import com.lei2j.dubbo.service.AsyncDubboService;
import org.apache.dubbo.config.annotation.Service;

import java.util.concurrent.CompletableFuture;

/**
 * author: 98611
 * date: 2019/7/14
 */

@Service(timeout = 5000)
public class AsyncDubboServiceImpl implements AsyncDubboService {
    @Override
    public String future(String name) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("future:"+name);
        return "future:"+name;
    }

    @Override
    public CompletableFuture<String> async(String name) {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return CompletableFuture.completedFuture(name);
    }
}
